﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HotelApp
{
    #region AdminInfo

    public class AdminInfo : ObjectHotelApp
    {
        public string UserCode { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string Phone { get; set; }
        public string Email { get; set; }
        public DateTime CreateDate { get; set; }

        public AdminInfo() { }

        #region override

        public override IDictionary<string, string> ToDictionary()
        {
            IDictionary<string, string> dicRet = base.ToDictionary();

            dicRet.Add("UserCode", this.UserCode);
            dicRet.Add("UserName", this.UserName);
            dicRet.Add("Password", this.Password);
            dicRet.Add("Phone", this.Phone == null ? string.Empty : this.Phone);
            dicRet.Add("Email", this.Email == null ? string.Empty : this.Email);
            dicRet.Add("CreateDate", this.CreateDate == DateTime.MinValue ? "" : this.CreateDate.ToString(AppConfigurer.DateFormat));
            return dicRet;
        }

        public override IDictionary<string, PropertyErrorType> CheckData(bool isBeforeSave)
        {
            IDictionary<string, PropertyErrorType> dicRet = base.CheckData(isBeforeSave);
            if (!isBeforeSave)
                CheckPropertyForRequired(ref dicRet, "UserCode", this.UserCode);

            //Check fields
            CheckPropertyForRequired(ref dicRet, "UserName", this.UserName);
            CheckPropertyForRequired(ref dicRet, "Password", this.Password);

            return dicRet;
        }

        #endregion
    }

    #endregion

    #region NewsCategory

    public class NewsCategory : ObjectHotelApp
    {
        public string CategoryCode { get; set; }
        public string CategoryName { get; set; }
        public string CategoryDesc { get; set; }
        public DateTime CreateDate { get; set; }

        public NewsCategory() { }

        #region override

        public override IDictionary<string, string> ToDictionary()
        {
            IDictionary<string, string> dicRet = base.ToDictionary();

            dicRet.Add("CategoryCode", this.CategoryCode);
            dicRet.Add("CategoryName", this.CategoryName);
            dicRet.Add("CategoryDesc", this.CategoryDesc == null ? string.Empty : this.CategoryDesc);
            dicRet.Add("CreateDate", this.CreateDate == DateTime.MinValue ? "" : this.CreateDate.ToString(AppConfigurer.DateFormat));
            return dicRet;
        }

        public override IDictionary<string, PropertyErrorType> CheckData(bool isBeforeSave)
        {
            IDictionary<string, PropertyErrorType> dicRet = base.CheckData(isBeforeSave);
            if (!isBeforeSave)
                CheckPropertyForRequired(ref dicRet, "CategoryCode", this.CategoryCode);

            //Check fields
            CheckPropertyForRequired(ref dicRet, "CategoryName", this.CategoryName);
            //CheckPropertyForRequired(ref dicRet, "CategoryDesc", this.CategoryDesc);

            return dicRet;
        }

        #endregion
    }

    #endregion

    #region NewsInfo

    public class NewsInfo : ObjectHotelApp
    {
        public string NewsCode { get; set; }
        public string CategoryCode { get; set; }
        public string NewsName { get; set; }
        public string NewsDesc { get; set; }
        public string NewsContent { get; set; }
        public string Creator { get; set; }
        public DateTime CreateDate { get; set; }

        public NewsInfo() { }

        #region override

        public override IDictionary<string, string> ToDictionary()
        {
            IDictionary<string, string> dicRet = base.ToDictionary();

            dicRet.Add("NewsCode", this.NewsCode);
            dicRet.Add("CategoryCode", this.CategoryCode);
            dicRet.Add("NewsName", this.NewsName);
            dicRet.Add("NewsDesc", this.NewsDesc == null ? string.Empty : this.NewsDesc);
            dicRet.Add("NewsContent", this.NewsContent);
            dicRet.Add("Creator", this.Creator);
            dicRet.Add("CreateDate", this.CreateDate == DateTime.MinValue ? "" : this.CreateDate.ToString(AppConfigurer.DateFormat));
            return dicRet;
        }

        public override IDictionary<string, PropertyErrorType> CheckData(bool isBeforeSave)
        {
            IDictionary<string, PropertyErrorType> dicRet = base.CheckData(isBeforeSave);
            if (!isBeforeSave)
                CheckPropertyForRequired(ref dicRet, "NewsCode", this.CategoryCode);

            //Check fields
            CheckPropertyForRequired(ref dicRet, "CategoryCode", this.CategoryCode);
            CheckPropertyForRequired(ref dicRet, "NewsName", this.NewsName);
            CheckPropertyForRequired(ref dicRet, "NewsContent", this.NewsContent);
            CheckPropertyForRequired(ref dicRet, "Creator", this.Creator);

            return dicRet;
        }

        #endregion
    }

    #endregion

    #region ImageCategory

    public class ImageCategory : ObjectHotelApp
    {
        public string CategoryCode { get; set; }
        public string CategoryName { get; set; }
        public string CategoryDesc { get; set; }
        public DateTime CreateDate { get; set; }

        public ImageCategory() { }

        #region override

        public override IDictionary<string, string> ToDictionary()
        {
            IDictionary<string, string> dicRet = base.ToDictionary();

            dicRet.Add("CategoryCode", this.CategoryCode);
            dicRet.Add("CategoryName", this.CategoryName);
            dicRet.Add("CategoryDesc", this.CategoryDesc == null ? string.Empty : this.CategoryDesc);
            dicRet.Add("CreateDate", this.CreateDate == DateTime.MinValue ? "" : this.CreateDate.ToString(AppConfigurer.DateFormat));
            return dicRet;
        }

        public override IDictionary<string, PropertyErrorType> CheckData(bool isBeforeSave)
        {
            IDictionary<string, PropertyErrorType> dicRet = base.CheckData(isBeforeSave);
            if (!isBeforeSave)
                CheckPropertyForRequired(ref dicRet, "CategoryCode", this.CategoryCode);

            //Check fields
            CheckPropertyForRequired(ref dicRet, "CategoryName", this.CategoryName);
            //CheckPropertyForRequired(ref dicRet, "CategoryDesc", this.CategoryDesc);

            return dicRet;
        }

        #endregion
    }

    #endregion

    #region ImageInfo

    public class ImageInfo : ObjectHotelApp
    {
        public string ImageCode { get; set; }
        public string CategoryCode { get; set; }
        public string ImageName { get; set; }
        public string ImageDesc { get; set; }
        public string ImageType { get; set; }
        public string FileName { get; set; }
        public string FileNewName { get; set; }
        public string FilePath { get; set; }
        public string ThumbnailPath { get; set; }
        public string Creator { get; set; }
        public DateTime CreateDate { get; set; }
        public int DisplayOrder { get; set; }
        public bool IsVisible { get; set; }

        public ImageInfo()
        {
            IsVisible = true;
        }

        public override IDictionary<string, string> ToDictionary()
        {
            IDictionary<string, string> dicRet = base.ToDictionary();

            dicRet.Add("ImageCode", this.ImageCode);
            dicRet.Add("CategoryCode", this.CategoryCode);
            dicRet.Add("ImageName", this.ImageName);
            dicRet.Add("ImageDesc", this.ImageDesc == null ? string.Empty : this.ImageDesc);
            dicRet.Add("ImageType", this.ImageType);
            dicRet.Add("FileName", this.FileName);
            dicRet.Add("FileNewName", this.FileNewName);
            dicRet.Add("FilePath", this.FilePath);
            dicRet.Add("ThumbnailPath", this.ThumbnailPath);
            dicRet.Add("Creator", this.Creator);
            dicRet.Add("CreateDate", this.CreateDate == DateTime.MinValue ? "" : this.CreateDate.ToString(AppConfigurer.DateFormat));
            dicRet.Add("DisplayOrder", this.DisplayOrder.ToString());
            return dicRet;
        }

        public override IDictionary<string, PropertyErrorType> CheckData(bool isBeforeSave)
        {
            IDictionary<string, PropertyErrorType> dicRet = base.CheckData(isBeforeSave);
            if (!isBeforeSave)
                CheckPropertyForRequired(ref dicRet, "ImageCode", this.CategoryCode);

            //Check fields
            CheckPropertyForRequired(ref dicRet, "CategoryCode", this.CategoryCode);
            CheckPropertyForRequired(ref dicRet, "ImageName", this.ImageName);
            CheckPropertyForRequired(ref dicRet, "ImageType", this.ImageType);
            CheckPropertyForRequired(ref dicRet, "FileName", this.FileName);
            CheckPropertyForRequired(ref dicRet, "FileNewName", this.FileName);
            CheckPropertyForRequired(ref dicRet, "FilePath", this.FilePath);

            return dicRet;
        }
    }

    #endregion
}
